import axiosObj from "../../component/interceptor.js";

new Vue({
    el: "#app",
    data: function() {
        return {
            name: "",
            account: "",
            password: "",

            store_name: "",
            detail: "",
            logoPath: "",
            scope: "",
            connect: "",

            phone: "",
            address: "",

            visible1: true,
            visible2: false,
        }
    },
    methods: {
        u_register() {
            const _this = this
            axiosObj({
                method: "post",
                url: "/register",
                data: {
                    name: _this.name,
                    account: _this.account,
                    password: _this.password
                }
            }).then(function(result) {
                if (result.data.code === 1000) {
                    _this.$message.success("注册成功")
                    setTimeout(function() {
                        window.location.assign("/login")
                    }, 1000);
                } else {
                    _this.$message.error(result.data.msg)
                }
            }).catch(function(err) {
            })
        },
        s_register() {
            const _this = this
            axiosObj({
                method: "post",
                url: "/registerseller",
                data: {
                    name: _this.name,
                    account: _this.account,
                    password: _this.password,
                    store_name: _this.store_name,
                    detail: _this.detail,
                    logoPath: _this.logoPath,
                    scope: _this.scope,
                    connect: _this.connect,
                    phone: _this.connect,
                    address: _this.address,
                }
            }).then(function(result) {
                if (result.data.code === 1000) {
                    _this.$message.success("注册成功")
                    setTimeout(function() {
                        window.location.assign("/login")
                    }, 1000);
                } else {
                    _this.$message.error(result.data.msg)
                }
            }).catch(function(err) {
            })
        },
        change_s_register() {
            this.visible1 = false;
            this.visible2 = true;
        },
        change_u_register() {
            this.visible1 = true;
            this.visible2 = false;
        },
        login() {
            window.location.replace("/login")
        },

    }
})